package com.sunagy.demand.front.controller;

import com.sunagy.demand.front.VO.ResultVO;
import com.sunagy.demand.front.dataobject.CustomerProgressPaper;
import com.sunagy.demand.front.dto.CustomerProgressPaperDto;
import com.sunagy.demand.front.service.CustomerProgressPaperService;
import com.sunagy.demand.front.utils.ResultVOUtil;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * desc：#TODO fill me ！
 * author：三餘無夢生
 * date：2018/5/15
 * time：下午1:37
 */
@Slf4j
@RestController
@RequestMapping("/customerProgressPaper")
@Api(value = "客户端进程相关材料", description = "需求互动过程中完成的某个进程相关的材料接口")
public class CustomerProgressPaperController {

    @Autowired
    private CustomerProgressPaperService customerProgressPaperService;

    @ApiOperation(value = "查询某个进程相关材料", notes = "根据用户进程id查询该进程相关的材料")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "java.lang.String", name = "Authorization", value = "token", required = false, paramType = "header"),
            @ApiImplicitParam(dataType = "java.lang.String", name = "id", value = "进程id", required = false, paramType = "path")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "接口异常")
    })
    @RequestMapping(value = "/list/{id}", method = RequestMethod.GET)
    public ResultVO<List<CustomerProgressPaperDto>> getList(@PathVariable("id") Integer customerProgressId) {
        List<CustomerProgressPaperDto> customerProgressPaperDtoList = customerProgressPaperService.getListByCustomerProgressId(customerProgressId);
        return ResultVOUtil.success(customerProgressPaperDtoList);
    }

    @ApiOperation(value = "新增进程材料", notes = "新增一个进程材料")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "java.lang.String", name = "Authorization", value = "token", required = false, paramType = "header"),
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "接口异常")
    })
    @RequestMapping(value = "",method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultVO<CustomerProgressPaperDto> pickProduct(@RequestBody CustomerProgressPaper customerProgressPaper) {
        CustomerProgressPaperDto customerProgressPaperDto = customerProgressPaperService.add(customerProgressPaper);
        return ResultVOUtil.success(customerProgressPaperDto);
    }
}
